home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / c / bevel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-04  |  2.5 KB  |  96 lines

  1. /*
  2. ** ACE run-time library module: bevel-box function.
  3. ** Copyright (C) 1998 David Benn
  4. ** 
  5. ** This program is free software; you can redistribute it and/or
  6. ** modify it under the terms of the GNU General Public License
  7. ** as published by the Free Software Foundation; either version 2
  8. ** of the License, or (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. **
  19. ** Author: David J Benn
  20. **   Date: 20th,24th,30th June 1994
  21. */
  22.  
  23. #include <exec/types.h>
  24. #include <intuition/intuition.h>
  25.  
  26. #define RAISED         1L
  27. #define RECESSED     2L
  28. #define STRGADBOX    3L
  29.  
  30. /* externals */
  31. extern    struct RastPort *RPort;
  32.  
  33. /* functions */
  34. void    BevelBox(style,y2,x2,y1,x1)
  35. ULONG     style,x1,y1,x2,y2;        
  36. {
  37. /*
  38. ** Render a 3D bevel-box in one of 3 styles.
  39. */
  40. ULONG     width,height;
  41. BYTE    old_fgpen;
  42.  
  43.     if (y1 > y2 || x1 > x2 ||
  44.        (style != RAISED && 
  45.         style != RECESSED && 
  46.         style != STRGADBOX)) return;
  47.  
  48.     width  = x2-x1;
  49.     height = y2-y1;
  50.  
  51.     old_fgpen = RPort->FgPen;
  52.  
  53.     if (style == RAISED)
  54.     {
  55.         /* raised 3D style */
  56.  
  57.         SetAPen(RPort,1L);
  58.         Move(RPort,x2,y1); Draw(RPort,x2,y2);       /* rt side */
  59.         Move(RPort,x2-1,y1); Draw(RPort,x2-1,y2-1); /* rt thickening */
  60.         Move(RPort,x1,y2); Draw(RPort,x2,y2);        /* bottom */    
  61.  
  62.         SetAPen(RPort,2L);
  63.         Move(RPort,x1,y1); Draw(RPort,x1,y2);        /* lt side */
  64.         Move(RPort,x1+1,y1); Draw(RPort,x1+1,y2-1); /* lt thickening */
  65.         Move(RPort,x1,y1); Draw(RPort,x2-1,y1);     /* top */    
  66.  
  67.         /* reset fgnd pen colour */
  68.         SetAPen(RPort,old_fgpen);
  69.     }
  70.     else
  71.     if (style == RECESSED)
  72.     {
  73.         /* recessed 3D style */
  74.  
  75.         SetAPen(RPort,2L);
  76.         Move(RPort,x2,y1); Draw(RPort,x2,y2);        /* rt side */
  77.         Move(RPort,x2-1,y1); Draw(RPort,x2-1,y2-1); /* rt thickening */
  78.         Move(RPort,x1,y2); Draw(RPort,x2,y2);        /* bottom */    
  79.  
  80.         SetAPen(RPort,1L);
  81.         Move(RPort,x1,y1); Draw(RPort,x1,y2);        /* lt side */
  82.         Move(RPort,x1+1,y1); Draw(RPort,x1+1,y2-1); /* lt thickening */
  83.         Move(RPort,x1,y1); Draw(RPort,x2-1,y1);     /* top */    
  84.  
  85.         /* reset fgnd pen colour */
  86.         SetAPen(RPort,old_fgpen);
  87.     }
  88.     else
  89.     {
  90.         /* new look 3D string gadget */
  91.  
  92.         BevelBox(RAISED,y2,x2,y1,x1);        
  93.         BevelBox(RECESSED,y2-1,x2-2,y1+1,x1+2);        
  94.     }
  95. }
  96.